<?php

/**
 * security actions.
 *
 * @package    budgetpulse
 * @subpackage security
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class securityActions extends BaseActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->forward('default', 'module');
  }
  
  public function executeLogin(sfWebRequest $request) {
    $this->success = false;
    $this->loggedin = false;
    $this->message = "";
    
    $httpService = new HttpService();
    
    try {
      $this->loggedin = $httpService->login(
        $request->getParameter('username'),
        $request->getParameter('password'));
      $this->success = true;
    }
    catch (HttpException $e) {
      $this->success = true;
      $this->message = $e->getMessage();
    }
    catch (Exception $e) {
      $this->success = false;
      $this->message = $e->getMessage();
    }
    
    return $this->renderJSON();
  }
}
